<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<%@include file="/includes.jsp"%>

<% int total = ((Integer)session.getAttribute("total")).intValue(); %>
<% total = total != 0? total: 1; %>
<jsp:useBean id="durationHours" class="java.util.Date"/>
<jsp:useBean id="durationMins" class="java.util.Date"/>
<jsp:useBean id="remainingHours" class="java.util.Date"/>
<jsp:useBean id="remainingMins" class="java.util.Date"/>
        
<div class="layout">
    <div style="float: right; width=0%;">
        <table class="details" cellspacing="0">
            <tr>
                <th class="details">Period</th>
                <td class="details">
                    <beans:write name="sprintValue" property="startDate" format="yyyy-MM-dd"/>
                    to<br/>
                    <beans:write name="sprintValue" property="stopDate" format="yyyy-MM-dd"/>
                </td>
            </tr>
            <tr>
                <th class="details">Scrum Master</th>
                <td class="details">
                    <html:link action="showNode.do" paramId="nodeId" paramName="sprintValue" paramProperty="scrumMasterValue.contactableValue.nodeValue.nodeId">
                        <beans:write name="sprintValue" property="scrumMasterValue.contactableValue.nodeValue.name"/>
                    </html:link>
                </td>
            </tr>
            <tr>
                <th class="details">Team</th>
                <td class="details">
                    <logic:iterate name="teamValues" id="team">
                        <html:link action="showNode.do" paramId="nodeId" paramName="team" paramProperty="contactableValue.nodeValue.nodeId">
                            <beans:write name="team" property="contactableValue.nodeValue.name"/><br/>
                        </html:link>
                    </logic:iterate>
                </td>
            </tr>
        </table>
    </div>
    <img src="<html:rewrite page='/icons/sprint-32x32.png'/>"/><span class="node-name"><beans:write name="sprintValue" property="nodeValue.name"/></span>
    <p class="history">
        <span class="history-text">
            <velocityme:markup><beans:write name="sprintValue" property="nodeValue.description"/></velocityme:markup>
        </span>
    </p>
    <h2>Progress</h2>
    <table class="styled" cellspacing="0">
        <tr>
            <th class="styled">Task</th>
            <th class="styled">Duration</th>
            <th class="styled">Remaining</th>
            <th class="styled">Graphical</th>
        </tr>
        <logic:iterate name="progressValue" id="progress">
            <tr>
                <td class="styled">
                    <html:link action="showNode.do" paramId="nodeId" paramName="progress" paramProperty="taskValue.taskId">
                        <beans:write name="progress" property="taskName"/><beans:write name="progress" property="taskValue.nodeValue.name"/>
                    </html:link>
                </td>
                <jsp:setProperty name="durationHours" property="time" value="<%=((ProgressDTO)progress).getDuration_min()/60%>"/>
                <jsp:setProperty name="durationMins" property="time" value="<%=((ProgressDTO)progress).getDuration_min()%60%>"/>
                <td class="styled"><beans:write name="durationHours" property="time" format="##"/>h:<beans:write name="durationMins" property="time" format="00"/>m</td>
                <jsp:setProperty name="remainingHours" property="time" value="<%=((ProgressDTO)progress).getRemaining_min()/60%>"/>
                <jsp:setProperty name="remainingMins" property="time" value="<%=((ProgressDTO)progress).getRemaining_min()%60%>"/>
                <td class="styled"><beans:write name="remainingHours" property="time" format="##"/>h:<beans:write name="remainingMins" property="time" format="00"/>m</td>
                <td class="styled">
                    <logic:equal name="progress" property="taskValue.stateValue.nodeValue.name" value="Start State">
                        <div class="histogram-complete" style="float: left; width: <%=((ProgressDTO)progress).getDuration_min()*100/total%>%">&nbsp;</div>
                    </logic:equal>
                    <logic:notEqual name="progress" property="taskValue.stateValue.nodeValue.name" value="Start State">
                        <div class="histogram" style="float: left; width: <%=((ProgressDTO)progress).getDuration_min()*100/total%>%">&nbsp;</div>
                    </logic:notEqual>
                    <div class="histogram-remaining" style="float: left; width: <%=((ProgressDTO)progress).getRemaining_min()*100/total%>%">&nbsp;</div>
                </td>
            </tr>
        </logic:iterate>
    </table>
</div>
